package com.chat.admin.config.redis;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    @Value("${spring.data.redis.host}")
    String host;
    @Value("${spring.data.redis.port}")
    String port;
    @Value("${spring.data.redis.password}")
    String password;

    @Bean(destroyMethod="shutdown")
    public RedissonClient redissonClient() {
        //配置类
        Config config = new Config();
        //添加redis地址（目前是单点地址）
//        config.useClusterServers().addNodeAddress("redis://" + host + ":" + port).setPassword(password);
        config.useSingleServer().setAddress("redis://8.134.139.46:6379").setPassword("123asdfASDF789");
        //创建客户端
        return Redisson.create(config);
    }
}
